namespace Altairis.FluffyCloud.Data.Migrations
{
    using System;
    using System.Data.Entity.Migrations;
    
    public partial class AddedTopicUserStates : DbMigration
    {
        public override void Up()
        {
            CreateTable(
                "dbo.TopicUserStates",
                c => new
                    {
                        TopicUserStatusId = c.Guid(nullable: false),
                        TopicId = c.Int(nullable: false),
                        UserName = c.String(nullable: false, maxLength: 100),
                        LastVisitDate = c.DateTimeOffset(nullable: false),
                        IsBookmarked = c.Boolean(nullable: false),
                    })
                .PrimaryKey(t => t.TopicUserStatusId)
                .ForeignKey("dbo.Topics", t => t.TopicId, cascadeDelete: true)
                .ForeignKey("dbo.Users", t => t.UserName, cascadeDelete: false)
                .Index(t => t.TopicId)
                .Index(t => t.UserName);
            
        }
        
        public override void Down()
        {
            DropIndex("dbo.TopicUserStates", new[] { "UserName" });
            DropIndex("dbo.TopicUserStates", new[] { "TopicId" });
            DropForeignKey("dbo.TopicUserStates", "UserName", "dbo.Users");
            DropForeignKey("dbo.TopicUserStates", "TopicId", "dbo.Topics");
            DropTable("dbo.TopicUserStates");
        }
    }
}
